<!-- 申请退场详情 -->
<template>
	<view class="web-page">
			<!-- <view class="flex justify-center align-center py-3">
				<u--image v-if="obj.status==1" src="/static/images/ui/salary/wait.png" width="148rpx" height="148rpx"></u--image>
				<u--image v-if="obj.status==2" src="/static/images/ui/salary/pass.png" width="148rpx" height="148rpx"></u--image>
				<u--image v-if="obj.status==3" src="/static/images/ui/salary/unpass.png" width="148rpx" height="148rpx"></u--image>
			</view> -->
	
			<web-view :update-title="false" :fullscreen="false" :src="obj.signUrl"></web-view>
			<!-- <view class="p-3" style="position: absolute; bottom: 520rpx; width: 100%;">
				<view class="bt-block mb-3">
					<bg-title class="margin-top mx-3">
						<text class="font-1">流程节点图</text>
					</bg-title>
					<view class="p-3">
						<bg-step :list="obj.auditRecordList"></bg-step>
					</view>
				</view>
			</view> -->
			
			<view class="bt-footer bt-gap" v-if="showAudit" style="position: absolute;bottom: 0;">
				<bg-btn plain @click="audit(3)">审批未通过</bg-btn>
				<bg-btn @click="audit(2)">审批通过</bg-btn>
			</view>
	</view>
</template>

<script>
	import {retireDetail, manageAudit, leaderAudit} from "@/api/retire.js"
	export default {
		onLoad(options){
			this.id = options.id
			this.getData()
		},
		onNavigationBarButtonTap(e) {
			uni.$emit('page-popup', {
				authList:this.authList
			});
			const subNVue = uni.getSubNVueById('auth-step')
			subNVue.show('slide-in-top', 250)
		},
		created() {
			// #ifdef APP-PLUS
				var currentWebview = this.$mp.page.$getAppWebview(); //获取当前web-view
				setTimeout(function() {
				var wv = currentWebview.children()[0];
				this.wv = wv
				wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度，单位为px
						top:20,
					})
				}, 1000);
			// #endif	
		},
		data() {
			return {
				authList:[],
				wv:null,
				id:'',
				obj:'',
				realUrl:'',
				wsStyle:{
					height:'680px'
				}
			}
		},
		computed:{
			wsObject(){
				if(this.showAudit){
					return {height:"570px"}
				} else{
					return {height:"680px"}
				}
			},
			showAudit(){
				return this.obj.status==1&&this.$auth.hasRoleOr(['team','project'])&&this.obj.auditUserId==this.$store.getters.userId
			}
		},
		methods: {
			
			getData(){
				retireDetail(this.id).then(res=>{
					this.obj = res.data;
					this.authList = [
						{auditUserName:this.obj.createUserName, auditTime:this.obj.createTime},
						...this.obj.auditRecordList
					]
					// #ifdef APP-PLUS
						var currentWebview = this.$mp.page.$getAppWebview(); //获取当前web-view
						var wv = currentWebview.children()[0];
						this.wv = wv
						uni.getSystemInfo({
							success:({windowHeight})=>{
								console.log(windowHeight)
								setTimeout(()=>{
									if(this.showAudit){
										wv.setStyle({height:windowHeight-40})
									} else {
										wv.setStyle({height:windowHeight})
									}
								}, 1000);
							}
						})
						
					// #endif	
				})
			},
			
			audit(status){
				let method = null
				if(this.$auth.hasRole("team")){
					method = leaderAudit
				}
				if(this.$auth.hasRole("project")){
					method = manageAudit
				}
				
				if(method){
					method({id:this.id, status:status}).then(res=>{
						this.$modal.msg('审批成功')
						uni.$emit("refresh-retire", true)
						this.$tab.navigateBackDelay()
					})
				}
			}
		}
	}
</script>

<style scoped>
	.web-page {
		overflow: auto;
		height: calc(100vh+250rpx);
	}
</style>
